package com.ahwei.product.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 这是一个Java文件！
 * </p>
 *
 * @author ahWei
 * @email：ahwei163@qq.com
 * @since 2022-06-01 14:50:19
 */
@RestController
public class NacosConfigController2 {
    /**
     *  // 注入配置文件上下文
     */
    @Autowired
    private ConfigurableApplicationContext applicationContext;

    @GetMapping("/datasourceUrl")
    public String datasourceUrl() {
        //读取nacos服务器中的配置信息
        return applicationContext.getEnvironment().getProperty("spring.datasource.url");
    }
}